#include "designersettings.h"
#include "ui_designersettings.h"
#include "settings.h"
#include <QFileDialog>

DesignerSettings::DesignerSettings(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DesignerSettings)
{
    ui->setupUi(this);
    m_settings = Settings::instance();
    ui->scripterPathEdit->setText(m_settings->scripterPath());
}

DesignerSettings::~DesignerSettings()
{
    delete ui;
}

void DesignerSettings::done(int res)
{
    if(res == QDialog::Accepted) {
        m_settings->setScripterPath( ui->scripterPathEdit->text() );
        m_settings->save();
    }
    QDialog::done(res);
}
#include <QDebug>
void DesignerSettings::on_browseFileUis_clicked()
{
    QString filter;
#ifdef Q_OS_WIN
    filter = tr("Executable (*.exe)");
#else
    filter = tr("Executable (*.*)");
#endif
    QString fileName = QFileDialog::getOpenFileName(this,
        tr("Select uiscripter"), "", filter);

    if(!fileName.isNull())
        ui->scripterPathEdit->setText(fileName);
}
